package com.tina.controller;


import com.tina.utils.ResultFormat;
import com.tina.utils.ResultUtil;
import com.tina.utils.ShortMessageUtil;
import org.apache.commons.lang3.StringUtils;
import org.springframework.stereotype.Controller;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.validation.Valid;

/**
 * @author Tina
 * @version 0.0.1
 * @date 2020/7/2 10:14
 * 发送短信
 **/
@Controller
public class ShortMessageController {

    @PostMapping("/shortMessage")
    @ResponseBody
    public ResultFormat shortMessage(String number) {
        System.out.println(number);
        if (StringUtils.isEmpty(number)) {
            return ResultUtil.error(100, "请输入手机号码");
        }
        boolean mobileNO = ShortMessageUtil.isMobileNO(number);
        if (mobileNO) {
            Integer sendMsg = ShortMessageUtil.SendMsg(number);
            return ResultUtil.success(sendMsg);
        }
        return ResultUtil.error(100, "手机号码输入错误");

    }

}
